home *** CD-ROM | disk | FTP | other *** search
/ Singles Flirt Up Your Life! (German) / Singles Flirt Up Your Life.iso / data1.cab / Statemachine / trashcan.lua < prev    next >
Text File  |  2004-01-29  |  1KB  |  55 lines

  1. -- trashcan state machine
  2.  
  3. beginStateMachine()
  4.  
  5.  
  6.     onEnter(function(msg)
  7.         local fillLevel = retrieveData("fillLevel", 0.0);
  8.         storeData("fillLevel", fillLevel);
  9.         local stink = findChildGO("stink");
  10.         stink.setEmitRate(0.0);
  11.     end )
  12.  
  13.  
  14.     onMsg("buildMenu", function(msg)
  15.     
  16.         if (repairMenu()) then return end
  17.     
  18.         -- build the pie menu
  19.         clearPieMenu();
  20.         
  21.         local button = addPieMenuButton("pm_bringOutTrash", "takeTrash");
  22.         button.addDescription(ACTIVITY, "takeTrash");
  23.         button.addDescription(ACTIVITY, "improveTrashTidiness");
  24.         button.addIcon("guiIconWohnung");
  25.  
  26.     end )
  27.  
  28.     -- 
  29.     onMsg("takeTrash", function(msg)
  30.         -- get the game object server
  31.         local gameObjectServer = getGameObjectServer();
  32.         -- get character who initiated this action
  33.         local character = getStateObjectFromID(msg.sender);
  34.         -- walk to the closest action point
  35.         local actionPoint = character.getClosestFreeActionPoint(character, this, {"take1", "take2", "take3", "take4",
  36.         "take5", "take6", "take7", "take8"});
  37.  
  38.         if (actionPoint) then
  39.             -- get the walk state object
  40.             local wso = character.walkSO;
  41.             if (wso.walkToActionPoint(actionPoint)) then
  42.                 wso.queueStateMachine("trashcanChar.takeTrash", this);
  43.             else
  44.                 print("no path found");
  45.                 instantAbort(character, EMOTICON_NOPATH, "emoThink")
  46.             end
  47.         else
  48.             print("no action point found");
  49.             instantAbort(character, EMOTICON_CANNOT, "emoThink")
  50.         end
  51.     end )
  52.             
  53.             
  54. endStateMachine()
  55.